package com.financing.wap.dao.impl;

import java.sql.SQLException;
import java.util.List;

import org.springframework.stereotype.Repository;





import com.financing.wap.common.SqlName;
import com.financing.wap.dao.IClientDao;
import com.financing.wap.dto.ClientUserBaseDTO;
import com.financing.wap.dto.CorpClientUserBaseDTO;
import com.financing.wap.vo.QueryClientUserVo;

@Repository("clientDao")
@SuppressWarnings(value={"deprecation","unchecked"})
public class ClientDaoImpl extends BaseDaoImpl<ClientUserBaseDTO, java.lang.Integer> implements IClientDao {

	public List<ClientUserBaseDTO> getClientUserList(QueryClientUserVo queryVo) {
		List<ClientUserBaseDTO> result = this.getSqlMapClientTemplate().queryForList(SqlName.CLIENT_USER_LIST,queryVo);
		return result;
	}

	public int getClientUserListCount(QueryClientUserVo queryVo) {
		Integer count = (Integer)this.getSqlMapClientTemplate().queryForObject(SqlName.CLIENT_USER_LIST_COUNT,queryVo);
		return count;
	}

	public ClientUserBaseDTO searchClientUserBaseById(Integer id) {
		ClientUserBaseDTO dto = (ClientUserBaseDTO)this.getSqlMapClientTemplate().queryForObject(SqlName.CLIENT_USER_INFO_ID,id);
		return dto;
	}

	public int insertClientUserBase(ClientUserBaseDTO dto) {
		Integer id = (Integer)this.getSqlMapClientTemplate().insert(SqlName.CLIENT_USER_INSERT,dto);
		return id;
	}

	public int updateClientUserBase(ClientUserBaseDTO dto) {
		this.getSqlMapClientTemplate().update(SqlName.CLIENT_USER_UPDATE,dto);
		return dto.getId();
	}


	
	@Override
	public Class<ClientUserBaseDTO> getEntityClass() {
		return ClientUserBaseDTO.class;
	}

	@Override
	public List<CorpClientUserBaseDTO> getCorpClientUserList(
			QueryClientUserVo queryVo) {
		List<CorpClientUserBaseDTO> result = this.getSqlMapClientTemplate().queryForList(SqlName.CLIENT_CORP_LIST,queryVo);
		return result;
	}

	@Override
	public int getCorpClientUserListCount(QueryClientUserVo queryVo) {
		Integer count = (Integer)this.getSqlMapClientTemplate().queryForObject(SqlName.CLIENT_CORP_LIST_COUNT,queryVo);
		return count;
	}

	@Override
	public int deleteClient(ClientUserBaseDTO dto) throws SQLException {
		return this.sqlMapClientTemplate.delete(SqlName.DELETE_CLIENT_USER_BASE,dto);
	}

}
